package com.xyz.graph.service.impl;


import com.xyz.graph.common.CommonResult;
import com.xyz.graph.exception.BuiltinSearchException;
import com.xyz.graph.service.BuiltinSearchOperation;
import com.xyz.graph.service.GSelectService;
import com.xyz.graph.util.CollectionUtil;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
public class GSelectServiceImpl implements GSelectService {

    @Autowired
    BuiltinSearchOperation builtinSearchOperation;
    @Override
    public HashMap<String, ArrayList<HashMap<String, String>>> entityExtend(GraphTraversalSource g, String id, int step, String[] relationTypes, String field, boolean alldata) {
        List<ArrayList<HashMap<String,String>>> list;
        try{
            list = builtinSearchOperation.entityExtend(g,id,step,relationTypes,field,alldata);
        }catch(Exception e){
            throw new BuiltinSearchException(CommonResult.ERROR,"实体扩展计算失败：" + e.getMessage());
        }finally {

        }
        return CollectionUtil.list2Set(list);
    }
}
